/*
 * Generated via the com.flca generator
 */
package com.logica.hackthon.entity;
import com.flca.frw.dao.IEntity;
import com.logica.hackthon.entity.GamePlayer;
import java.io.Serializable;
import java.util.Date;
import java.util.Set;
import javax.persistence.*;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
/**
 * @todo add comment for javadoc
 *
 * @author robin
 * @version $Id: EntityClass.javajet,v 1.3 2007/06/29 21:48:03 robin bakkerus Exp $
 * @generated
 */
@Entity
@Table(name = "Game")
public class Game  implements Serializable, Cloneable, IEntity
{
	private static final long serialVersionUID = 123L;
	/** @generated */
	public Game() {
	}
	
	/** @generated */
	@Basic
@Column(name = "date", length = 255, precision = 0, scale = 0, columnDefinition = "")
	protected Date date = null;
	/** @generated */
	@OneToMany(cascade = {CascadeType.ALL}, fetch = FetchType.EAGER, mappedBy="parent")
	protected Set<GamePlayer> players = null;

	/**
	 * @todo add comment for javadoc
	 * Note a returned Set is always NOT null
	 * @generated
	 */
	public Date getDate() {
		return date;
	}
	/** @generated */
	public void setDate(Date date) {
		this.date = date;
	}
	
	/**
	 * @todo add comment for javadoc
	 * Note a returned Set is always NOT null
	 * @generated
	 */
	public Set<GamePlayer> getPlayers() {
		if (this.players == null) {
			this.players = new java.util.HashSet<GamePlayer>();        
		}
		return players;
	}
	/** @generated */
	public void setPlayers(Set<GamePlayer> players) {
		this.players = players;
	}
	
	/**
	* Use this method to find out if corresponding set is not null
	*/
	public boolean isPlayersNotNull() {
		return (this.players != null);
	}
	/**
	* Use this method to find out if corresponding set is null
	*/
	public boolean isPlayersNull() {
		return (this.players == null);
	}
		
	/**
	 * Associate Game with GamePlayer
	 * @generated
	 */
	public void addPlayer(GamePlayer player) {
		if (player == null) return;
		getPlayers().add(player);
		player.setParent(this);
	}
	/**
	 * Unassociate Game from GamePlayer
	 * @generated
	 */
	public void removePlayer(GamePlayer player) {
		if (player == null) return;
		getPlayers().remove(player);
		player.setParent(null);
	}

	
	/** @generated */
	public String toString() {
		return ToStringBuilder.reflectionToString(this,ToStringStyle.MULTI_LINE_STYLE);
	}	
	/** @generated */
	public int hashCode() {
		final int PRIME = 31;
		int result = 1;
		result = PRIME * result + ((getPk() == null) ? 0 : getPk().hashCode());
		return result;
	}
	/** @generated */
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final Game other = (Game) obj;
		if (getPk() != null) {
			return getPk().equals(other.getPk());
		} else {
			return false;
		}
	}		
	/** @generated */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long pk;
		
	public Long getPk() {
		return pk;
	}
	public void setPk(Long aValue) {
		if (aValue != null && aValue.longValue() == 0) {
			pk = null;
		} else {
			pk = aValue;
		}
	}
	
	//we need this because otherwise the AMF will not pass the pk to the AS class
	
	@Transient
	protected long pkValue = 0;
	
	public long getPkValue() {
		if (pk != null) {
			return pk.longValue();
		} else {
			return 0;
		}
	}
	
	public void setPkValue(long aValue) {
		if (aValue != 0) {
			pk = new Long(aValue);
		}
	}
	
}
